package com.eui.arch.application.model
{
	
	import com.eui.arch.util.ManagedPM;
	
	import flash.utils.getQualifiedClassName;
	
	import mx.controls.Alert;
	import mx.core.Application;
	import mx.events.CloseEvent;
	import mx.rpc.IResponder;

	public class NodePM extends ManagedPM
	{
		//Do we really need to block enter?
		//One thing: check whether the parameter is valid?
		public function enterNode(data:Object, responder:IResponder):void
		{
			responder.result(null);
		}

		public function exitNode(responder:IResponder):void
		{
			if (isDataChanged())
			{
				Alert.yesLabel = "Yes";
				Alert.noLabel = "No";
				Alert.show("You have unsaved changes. Do you want to continue?", "Unsaved Changes", 3, null, alertClickHandler);
				function alertClickHandler(event:CloseEvent):void{
					if (event.detail == Alert.YES)
					{
						responder.result(null);
					}
					else
					{
						responder.fault(null);
					}
				}
			}
			else
			{
				responder.result(null);
			}
		}

		public function isDataChanged():Boolean
		{
			return false;
		}
	}
}